/*
 * @file    rotated_array.cpp
 * @author  edward <libo@tencent.com>
 * @date    2013-04-04
 * @brief   
 * */

#include <iostream>
#include <vector>

int rotate_pivot(int ar[], int n) {
    int l = 0;
    int r = n - 1;
    while(ar[l] > ar[r]) {
        int m = l + (r - l) / 2;
        if(ar[m] > ar[r]) {
            l = m + 1;
        } else {
            r = m;
        }
    }
    return l;
}

int main() {
    int tmp[] = { 3, 4, 1, 2};
    std::cout << rotate_pivot(tmp, 4);
}
